package com.huluobo.jetpackkotlindemo2006a.livedata_viewmodel

import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider

/**
 * Created by lc on 2023/2/13.
 */
class FragmentB : Fragment() {
    lateinit var shareDataViewModel: ShareDataViewModel

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        shareDataViewModel = ViewModelProvider(this).get(ShareDataViewModel::class.java)

        //当A的标签发生变化时,同时改变B的标签
        shareDataViewModel.getCurrentPosition()
    }
}